package com.android.often.util.receiver;

import com.android.often.util.Operate;
import com.android.often.util.R;
import com.android.often.util.Util;

import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;

public class NotifiCation implements Operate{
	
	private final int NotificationID = 0x1100;
	private NotificationManager manager;
	private Notification notification;
	
	public NotifiCation(Activity activity)
	{
		manager = (NotificationManager) activity.getSystemService(Activity.NOTIFICATION_SERVICE);
		
		Intent intent = new Intent();
		intent.setClass(activity, Util.class);
		
		PendingIntent pendingIntent = PendingIntent.getActivity(activity, 0, intent, 0);
		notification = new Notification();
		notification.icon = R.drawable.icon;
		notification.tickerText ="Notification test...";
		notification.defaults = Notification.DEFAULT_SOUND;
		notification.setLatestEventInfo(activity, "notificationTitle", "notificationText", pendingIntent);
	}
	
	public void create()
	{
		manager.notify(NotificationID, notification);
	}
	
	@Override
	public void remove() {
		// TODO Auto-generated method stub
		manager.cancel(NotificationID);
	}
	
}